home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Resource for Source: C/C++
/
Resource for Source - C-C++.iso
/
codelib9
/
v_11_02
/
1102084a
< prev
next >
Wrap
Text File
|
1995-11-01
|
7KB
|
217 lines
case 16: /* image thresholding */
printf("\nCIPS> Enter input image name\n");
get_image_name(name);
printf("\nCIPS> Enter output image name\n");
get_image_name(name2);
get_parameters(&il, &ie, &ll, &le);
get_threshold_options(ts_method, &hi,
&low, &value);
if(ts_method[0] == 'm' ||
ts_method[0] == 'M')
manual_threshold_segmentation(name,
name2, the_image, out_image,
il, ie, ll, le,
hi, low, value, 0);
if(ts_method[0] == 'p' ||
ts_method[0] == 'P')
peak_threshold_segmentation(name,
name2, the_image, out_image,
il, ie, ll, le, value, 0);
if(ts_method[0] == 'v' ||
ts_method[0] == 'V')
valley_threshold_segmentation(name,
name2, the_image, out_image,
il, ie, ll, le, value, 0);
if(ts_method[0] == 'a' ||
ts_method[0] == 'a')
adaptive_threshold_segmentation(name,
name2, the_image, out_image,
il, ie, ll, le, value, 0);
break;
case 17: /* image segmentation */
printf("\nCIPS> Enter input image name\n");
get_image_name(name);
printf("\nCIPS> Enter output image name\n");
get_image_name(name2);
get_parameters(&il, &ie, &ll, &le);
get_segmentation_options(ts_method, &hi,
&low, &value);
if(ts_method[0] == 'm' ||
ts_method[0] == 'M')
manual_threshold_segmentation(name,
name2, the_image, out_image,
il, ie, ll, le,
hi, low, value, 1);
if(ts_method[0] == 'p' ||
ts_method[0] == 'P')
peak_threshold_segmentation(name,
name2, the_image, out_image,
il, ie, ll, le, value, 1);
if(ts_method[0] == 'v' ||
ts_method[0] == 'V')
valley_threshold_segmentation(name,
name2, the_image, out_image,
il, ie, ll, le, value, 1);
if(ts_method[0] == 'a' ||
ts_method[0] == 'a')
adaptive_threshold_segmentation(name,
name2, the_image, out_image,
il, ie, ll, le, value, 1);
break;
.
.
.
/******************************************************
*
* show_menu(..
*
* This function displays the CIPS main menu.
*
*******************************************************/
show_menu()
{
printf("\n\nWelcome to CIPS");
printf("\nThe C Image Processing System");
printf("\nThese are you choices:");
printf("\n\t1. Display image header");
printf("\n\t2. Show image numbers");
printf("\n\t3. Print image numbers");
printf("\n\t4. Display image (VGA & EGA only)");
printf("\n\t5. Display or print image using halftoning");
printf("\n\t6. Print graphics image using dithering");
printf("\n\t7. Print or display histogram numbers");
printf("\n\t8. Perform edge detection");
printf("\n\t9. Perform edge enhancement");
printf("\n\t10. Perform image filtering");
printf("\n\t11. Perform image addition and subtraction");
printf("\n\t12. Perform image cutting and pasting");
printf("\n\t13. Perform image rotation and flipping");
printf("\n\t14. Perform image scaling");
printf("\n\t15. Create a blank image");
printf("\n\t16. Perform image thresholding");
printf("\n\t17. Perform image segmentation");
printf("\n\t20. Exit system");
printf("\n\nEnter choice _\b");
} /* ends show_menu */
.
.
.
/********************************************
*
* get_segmentation_options(...
*
* This function interacts with the user
* to obtain the options for image
* segmentation.
*
*********************************************/
get_segmentation_options(method, hi, low, value)
char method[];
short *hi, *low, *value;
{
int i, not_finished = 1, response;
while(not_finished){
printf("\n\nThe image segmentation options are:\n");
printf("\n\t1. Method is %s", method);
printf("\n\t (options are manual peaks");
printf( " valleys adapative)");
printf("\n\t2. Value is %d", *value);
printf("\n\t3. Hi is %d", *hi);
printf("\n\t4. Low is %d", *low);
printf("\n\t Hi and Low needed only for");
printf( " manual method");
printf("\n\nEnter choice (0 = no change):_\b");
get_integer(&response);
if(response == 0)
not_finished = 0;
if(response == 1){
printf("\nEnter method (options are:");
printf(" manual peaks valleys adaptive)\n\t");
read_string(method);
}
if(response == 2){
printf("\nEnter value: ___\b\b\b");
get_short(value);
}
if(response == 3){
printf("\nEnter hi: ___\b\b\b");
get_short(hi);
}
if(response == 4){
printf("\nEnter low: ___\b\b\b");
get_short(low);
}
} /* ends while not_finished */
} /* ends get_segmentation_options */
/********************************************
*
* get_threshold_options(...
*
* This function interacts with the user
* to obtain the options for image
* threshold.
*
*********************************************/
get_threshold_options(method, hi, low, value)
char method[];
short *hi, *low, *value;
{
int i, not_finished = 1, response;
while(not_finished){
printf("\n\nThe image threshold options are:\n");
printf("\n\t1. Method is %s", method);
printf("\n\t (options are manual peaks");
printf( " valleys adapative)");
printf("\n\t2. Value is %d", *value);
printf("\n\t3. Hi is %d", *hi);
printf("\n\t4. Low is %d", *low);
printf("\n\t Hi and Low needed only for");
printf( " manual method");
printf("\n\nEnter choice (0 = no change):_\b");
get_integer(&response);
if(response == 0)
not_finished = 0;
if(response == 1){
printf("\nEnter method (options are:");
printf(" manual peaks valleys adaptive)\n\t");
read_string(method);
}
if(response == 2){
printf("\nEnter value: ___\b\b\b");
get_short(value);
}
if(response == 3){
printf("\nEnter hi: ___\b\b\b");
get_short(hi);
}
if(response == 4){
printf("\nEnter low: ___\b\b\b");
get_short(low);
}
} /* ends while not_finished */
} /* ends get_threshold_options */